package org.example.lotterysystem.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.example.lotterysystem.common.errorcode.ErrorCode;


@EqualsAndHashCode(callSuper = true) //不写可能会出现问题
@Data
public class ControllerException extends RuntimeException {
    /**
     * 异常码
     * @see org.example.lotterysystem.common.errorcode.ControllerErrorCodeConstants
     */
    private Integer code;
    /**
     * 异常消息
     *
     */
    private String message;
    //为了序列化
    private ControllerException() {

    }
    public ControllerException(Integer code, String message) {
        this.code = code;
        this.message = message;

    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
